﻿<%@ Page Language="C#" MasterPageFile="~/quickLMS.master" AutoEventWireup="true" CodeFile="ManageRoles.aspx.cs" Inherits="Admin_ManageRoles" Title="Manage Roles" %>
<%@ Register Assembly="Flan.Controls" Namespace="Flan.Controls" TagPrefix="cc1" %>
<asp:Content ID="Content1" ContentPlaceHolderID="ContentPlaceHolder1" Runat="Server">

<asp:UpdatePanel ID="update1" runat="server" UpdateMode="Conditional">
<ContentTemplate>

    <asp:GridView ID="grdRoles" runat="server" AutoGenerateColumns="False" SkinID="ROISkin">
    <Columns>
    <asp:TemplateField HeaderText="Delete">
        <ItemTemplate>
            <asp:LinkButton ID="lnkDelete" runat="server" Text="Delete" OnClientClick="return Confirm()" OnCommand="DeleteRole" CommandArgument='<%# Eval("RoleID") %>'></asp:LinkButton>
        </ItemTemplate>
    </asp:TemplateField>
    <asp:TemplateField HeaderText="Edit">
        <ItemTemplate>
            <asp:LinkButton ID="lnkEdit" runat="server" Text="Edit" CommandArgument='<%# Eval("RoleID") %>' OnCommand="OpenEditRole"></asp:LinkButton>
        </ItemTemplate>
    </asp:TemplateField>
    <asp:BoundField HeaderText="Role Name" DataField="RoleName" />
    </Columns>
     </asp:GridView>
     <br />
     <asp:LinkButton ID="lnkAddNew" runat="server" Text="Add New"></asp:LinkButton>
     <br />
     <asp:Label ID="lblStatus" runat="server" ForeColor="DarkRed"></asp:Label>
     
    <ajax:ModalPopupExtender id="ModalPopup1" runat="server" 
        TargetControlID="lnkAddNew"
        PopupControlID="pnlAddNew"
        CancelControlID="btnCancel"
        BackgroundCssClass="modalBackground"
        DropShadow="true">
    </ajax:ModalPopupExtender>
     
     <asp:Panel ID="pnlAddNew" runat="server" CssClass="modalPopup">
         <asp:Panel ID="pnlDragTitle" runat="server" CssClass="modalHeader">
            Add a New Role
         </asp:Panel>
         <br />
         <table width="100%">
            <tr>
                <td style="vertical-align: middle;">Role Name:</td>
                <td style="text-align: right;"><asp:TextBox ID="txtRoleName" runat="server"></asp:TextBox></td>
            </tr>
         </table>
         <asp:Button ID="btnConfirm" runat="server" Text="Add Role" OnClick="AddNewRole" />
         <asp:Button ID="btnCancel" runat="server" Text="Cancel"/>
     </asp:Panel>
     
     <cc1:UpdatePanelPopupExtender ID="EditRolePopupExtender" runat="server" TargetControlID="pnlEditRole"
        OffsetX="2" OffsetY="2" CalloutColor="#7C6F57" CalloutBorderColor="Black" AutoPostBack="True" 
        OnClose="pnlEditRoleClose"  />
        
        <asp:UpdatePanel ID="pnlEditRole" runat="server">
            <ContentTemplate>
                <asp:Panel ID="pnlEditRoleD" runat="server" CssClass="modalPopup">
                    <table>
                        <tr>
                            <td style="vertical-align: middle;">Role Name:</td>
                            <td style="text-align: right;"><asp:TextBox ID="txtEditRoleName" runat="server"></asp:TextBox></td>
                        </tr>
                    </table>
                    <asp:Button ID="btnEditConfirm" runat="server" Text="Edit Role" OnClick="EditRole" />
                    <asp:Button ID="btnEditCancel" runat="server" Text="Cancel" OnClick="pnlEditRoleClose"/>
                    <asp:HiddenField ID="hidRoleID" runat="server" />
                </asp:Panel>
            </ContentTemplate>
        </asp:UpdatePanel>
     
<script language="javascript" type="text/javascript">
    function Confirm()
    {
        return confirm("Are you sure you want to delete this role?");
    }
</script>
     
</ContentTemplate>
</asp:UpdatePanel>
</asp:Content>
